<template>
  <div>
    <div class="sb-w"
         v-for="(item, index) in menuData"
         :key="index">
      <el-submenu :index="item.id + ''"
                  v-if="item.childMenus && item.childMenus.length > 0"
                  :key="item.id + ''">
        <template slot="title">
          <i :class="item.icon"></i>
          <span slot="title">{{ item.menuName }}</span>
        </template>
        <Menu :menuData="item.childMenus"></Menu>
      </el-submenu>
      <el-menu-item class="mi-h"
                    v-else
                    :index="item.url + ''"
                    :route="item.url"
                    :key="item.id + ''">
        <i :class="item.icon"></i>
        <span>{{ item.menuName }}</span>
      </el-menu-item>
    </div>
  </div>
</template>

<script>
export default {
  //递归 这个名称要保持驼峰转短横线链接规则
  name: "Menu",
  props: {
    menuData: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  components: {},
  data () {
    return {};
  },
  created () { },
  mounted () { },
  methods: {},
};
</script>
<style lang='less' scoped>
.el-menu--collapse span,
.el-menu--collapse i.el-submenu__icon-arrow {
  height: 0;
  width: 0;
  overflow: hidden;
  visibility: hidden;
  display: inline-block;
}
.mi-h {
  height: 45px;
}
.sb-w {
  width: 100%;
}
</style>

